//
//  ParticleAnimation.m
//  DoodleMonopoly
//
//  Created by QuickSoluion on 12/10/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "ParticleAnimation.h"


@implementation ParticleAnimation

///--------------------------new---
@synthesize emitter;
@synthesize emitter_1;
@synthesize emitter_Explosion;
@synthesize emitter_Fire;
@synthesize emitter_Flower;
@synthesize emitter_Galaxy;
@synthesize emitter_Meteor;
@synthesize emitter_Rain;
@synthesize emitter_Smoke;
@synthesize emitter_Spiral;
@synthesize emitter_Sun;
@synthesize emitter_Button;
@synthesize emitter_SnowLand;
@synthesize emitter_extra;

////--------------------------/
-(void)initParticleEmitter
{
	self.emitter = [[CCParticleSnow alloc]init];//CCParticleSnow
	
	// testing "alpha" blending in premultiplied images
	self.emitter.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter.blendAdditive = YES;
	self.emitter.scaleX = 3.0;
	self.emitter.scaleY = 3.0;
	self.emitter.speed= 25.0;//7.0
}

-(CCParticleSystem *)particleEmiiterAt: (CGPoint) pos afterDelay: (float )delay
{
	//[self addChild: emitter z:10];
	self.emitter.life = 6;

	self.emitter.position = pos;
	self.emitter.autoRemoveOnFinish=YES;
	return [self.emitter autorelease] ;
	//[self performSelector:@selector(removeParticleEmitter:) withObject:emitter afterDelay:delay];
}

-(void) removeParticleEmitter:(id)sender {
	
	//[self removeChild:sender cleanup:YES];
}


///----------------------------------------------pha'o hoa------------------------------------------------------------------------------------------------------------------
-(void)initParticleEmitter_1
{
	self.emitter_1 =[[CCParticleFireworks alloc]init]; //[[CCParticleGalaxy alloc]init];
	

	self.emitter_1.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter_1.blendAdditive = YES;
	self.emitter_1.scaleX = 3.0;
	self.emitter_1.scaleY = 3.0;
}

-(CCParticleSystem *)particleEmiiterAt_1: (CGPoint) pos afterDelay: (float )delay
{	
	self.emitter_1.life = 6;
	self.emitter_1.position = pos;
	self.emitter_1.autoRemoveOnFinish=YES;
	return [self.emitter_1 autorelease];
	
}

///------------------------------------------Explosion-------------------------------------------------------------------------------------------------------------------------------------
-(void)initParticleEmitter_Explosion
{
	self.emitter_Explosion =[[CCParticleExplosion alloc]init];
	self.emitter_Explosion.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter_Explosion.blendAdditive = YES;
	self.emitter_Explosion.scaleX = 3.0;
	self.emitter_Explosion.scaleY = 3.0;
}
-(CCParticleSystem *)particleEmiiterAt_Explosion: (CGPoint) pos afterDelay: (float )delay
{
	
	self.emitter_Explosion.life = 6;
	self.emitter_Explosion.position = pos;
	self.emitter_Explosion.autoRemoveOnFinish=YES;
	return [self.emitter_Explosion autorelease];
	
}
///----------------------------------------------FIRE------------------------------------------------------------------------------------------
-(void)initParticleEmitter_Fire
{
	self.emitter_Fire =[[CCParticleFire alloc]init];
	self.emitter_Fire.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter_Fire.blendAdditive = YES;
	self.emitter_Fire.scaleX = 0.1;
	self.emitter_Fire.scaleY = 0.1;
	
}
-(CCParticleSystem *)particleEmiiterAt_Fire: (CGPoint) pos afterDelay: (float )delay
{
	self.emitter_Fire.emissionRate=1;
	self.emitter_Fire.life = 20;
	self.emitter_Fire.position = pos;
	self.emitter_Fire.autoRemoveOnFinish=YES;
	return [self.emitter_Fire autorelease];
	
}

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

///----------------------------------------------FLOWER------------------------------------------------------------------------------------------
-(void)initParticleEmitter_Flower
{
	self.emitter_Flower =[[CCParticleFlower alloc]init];
	self.emitter_Flower.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter_Flower.blendAdditive = YES;
	self.emitter_Flower.scaleX = 4.0;
	self.emitter_Flower.scaleY = 4.0;
}
-(CCParticleSystem *)particleEmiiterAt_Flower: (CGPoint) pos afterDelay: (float )delay
{
	self.emitter_Flower.speed=200;
	self.emitter_Flower.life = 5;
	self.emitter_Flower.position = pos;
	self.emitter_Flower.autoRemoveOnFinish=YES;
	return [self.emitter_Flower autorelease];
	
}

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
///----------------------------------------------GALAXY------------------------------------------------------------------------------------------
-(void)initParticleEmitter_Galaxy
{
	self.emitter_Galaxy =[[CCParticleGalaxy  alloc]init];
	self.emitter_Galaxy.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter_Galaxy.blendAdditive = YES;
	self.emitter_Galaxy.scaleX =1.0; //3.0;
	self.emitter_Galaxy.scaleY =1.0; //3.0;
}
-(CCParticleSystem *)particleEmiiterAt_Galaxy: (CGPoint) pos afterDelay: (float )delay
{
	self.emitter_Galaxy.speed=100;//100;
	self.emitter_Galaxy.life =3; //7;
	self.emitter_Galaxy.position = pos;
	self.emitter_Galaxy.autoRemoveOnFinish=YES;
	return [self.emitter_Galaxy autorelease];
	
}

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

///----------------------------------------------METEOR------------------------------------------------------------------------------------------
-(void)initParticleEmitter_Meteor
{
	self.emitter_Meteor =[[CCParticleMeteor  alloc]init];
	self.emitter_Meteor.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter_Meteor.blendAdditive = YES;
	self.emitter_Meteor.scaleX = 3.0;
	self.emitter_Meteor.scaleY = 3.0;
}
-(CCParticleSystem *)particleEmiiterAt_Meteor: (CGPoint) pos afterDelay: (float )delay
{
	
	self.emitter_Meteor.life = 6;
	self.emitter_Meteor.position = pos;
	self.emitter_Meteor.autoRemoveOnFinish=YES;
	return [self.emitter_Meteor autorelease];
	
}

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
///----------------------------------------------RAIN------------------------------------------------------------------------------------------
-(void)initParticleEmitter_Rain
{
	self.emitter_Rain =[[CCParticleRain  alloc]init];
	self.emitter_Rain.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter_Rain.blendAdditive = YES;
	self.emitter_Rain.scaleX = 3.0;
	self.emitter_Rain.scaleY = 3.0;
}
-(CCParticleSystem *)particleEmiiterAt_Rain: (CGPoint) pos afterDelay: (float )delay
{
	
	self.emitter_Rain.life = 8;
	self.emitter_Rain.position = pos;
	self.emitter_Rain.autoRemoveOnFinish=YES;
	return [self.emitter_Rain autorelease];
	
}

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

///----------------------------------------------SMOKE------------------------------------------------------------------------------------------
-(void)initParticleEmitter_Smoke
{
	self.emitter_Smoke =[[CCParticleSmoke  alloc]init];
	self.emitter_Smoke.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter_Smoke.blendAdditive = YES;
	self.emitter_Smoke.scaleX = 0.1;
	self.emitter_Smoke.scaleY = 0.1;
}
-(CCParticleSystem *)particleEmiiterAt_Smoke: (CGPoint) pos afterDelay: (float )delay
{
	self.emitter_SnowLand.emissionRate=1;
	self.emitter_SnowLand.startSize=0.1f;
	self.emitter_Smoke.life = 1;
	self.emitter_Smoke.position = pos;
	self.emitter_Smoke.autoRemoveOnFinish=YES;
	return [self.emitter_Smoke autorelease];
	
}

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

///----------------------------------------------SPIRAL------------------------------------------------------------------------------------------
-(void)initParticleEmitter_Spiral
{
	self.emitter_Spiral =[[CCParticleSpiral  alloc]init];
	self.emitter_Spiral.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter_Spiral.blendAdditive = YES;
	self.emitter_Spiral.scaleX = 3.0;
	self.emitter_Spiral.scaleY = 3.0;
}
-(CCParticleSystem *)particleEmiiterAt_Spiral: (CGPoint) pos afterDelay: (float )delay
{
	
	self.emitter_Spiral.life = 6;
	self.emitter_Spiral.position = pos;
	self.emitter_Spiral.autoRemoveOnFinish=YES;
	return [self.emitter_Spiral autorelease];
	
}

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

///----------------------------------------------SUN------------------------------------------------------------------------------------------
-(void)initParticleEmitter_Sun
{
	self.emitter_Sun =[[CCParticleSun  alloc]init];
	self.emitter_Sun.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter_Sun.blendAdditive = YES;
	self.emitter_Sun.scaleX = 3.0;
	self.emitter_Sun.scaleY = 3.0;
}
-(CCParticleSystem *)particleEmiiterAt_Sun: (CGPoint) pos afterDelay: (float )delay
{
	
	self.emitter_Sun.life = 6;
	self.emitter_Sun.position = pos;
	self.emitter_Sun.autoRemoveOnFinish=YES;
	return [self.emitter_Sun autorelease];
	
}

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

///----------------------------------------------ANIMATON BUTTON------------------------------------------------------------------------------------------
-(void)initParticleEmitter_Button
{
	self.emitter_Button =[[CCParticleSnow  alloc]init];
	self.emitter_Button.texture = [[CCTextureCache sharedTextureCache] addImage: @"stars.png"];
	self.emitter_Button.blendAdditive = YES;
	self.emitter_Button.scaleX = 3.0;
	self.emitter_Button.scaleY = 3.0;
}
-(CCParticleSystem *)particleEmiiterAt_Button: (CGPoint) pos afterDelay: (float )delay
{
	self.emitter_Button.contentSize=CGSizeMake(100, 100);
	
	self.emitter_Button.speed=10;
	self.emitter_Button.life = 8;
	self.emitter_Button.position = pos;
	self.emitter_Button.autoRemoveOnFinish=YES;
	return [self.emitter_Button autorelease];
	
}

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

-(void)initParticleEmiiter_SnowLandbyRandom
{
	int randomNumber=arc4random()%3;
	
	if(randomNumber!=1||randomNumber!=2||randomNumber!=3)
	{
		randomNumber=1;
	}
	NSString *strName=@"";
	switch (randomNumber) {
		case 1:
			//
			strName=@"bongtuyet1.png";
			break;
		case 2:
			//
			strName=@"bongtuyet2.png";
			break;
		case 3:
			//
			strName=@"bongtuyet3.png";
			break;		
		default:
			break;
	}
	
	NSLog(@"---%@",strName);
	
	self.emitter_SnowLand =[[CCParticleSnow  alloc]init];
	self.emitter_SnowLand.texture = [[CCTextureCache sharedTextureCache] addImage: [NSString stringWithFormat:@"%@",strName]];
	self.emitter_SnowLand.blendAdditive = YES;
	self.emitter_SnowLand.scaleX = 2.0;
	self.emitter_SnowLand.scaleY = 2.0;
		
}


-(CCParticleSystem *)particleEmiiter_SnowLandbyRandom: (CGPoint) pos afterDelay: (float )delay
{
	
	
	
	self.emitter_SnowLand.emissionRate=1;
	self.emitter_SnowLand.startSize=25.0f;
	
	
	self.emitter_SnowLand.angleVar=45;
	self.emitter_SnowLand.radialAccelVar=45;
	
	self.emitter_SnowLand.speed=14.0;
	self.emitter_SnowLand.life = 12;
	self.emitter_SnowLand.position = pos;
	self.emitter_SnowLand.autoRemoveOnFinish=YES;
	self.emitter_SnowLand.blendAdditive = YES;
	return [self.emitter_SnowLand autorelease];
	
	
}

-(void)initextra
{
	self.emitter_extra =[[CCParticleRain  alloc]init];
	self.emitter_extra.texture = [[CCTextureCache sharedTextureCache] addImage:@"bongtuyet4.png"];
	self.emitter_extra.blendAdditive = YES;
	self.emitter_extra.scaleX = 10.0;
	self.emitter_extra.scaleY = 10.0;
}
-(CCParticleSystem *)particleEmiiter_extra: (CGPoint) pos afterDelay: (float )delay
{
	self.emitter_extra.speed=15.0;
	self.emitter_extra.life = 12;
	self.emitter_extra.position = pos;
	self.emitter_extra.autoRemoveOnFinish=YES;

	return [self.emitter_extra autorelease];
}

-(void)dealloc
{
	
	[self.emitter release];// tuyet 
	[self.emitter_1 release];//phao hoa
	[self.emitter_Explosion release];
	[self.emitter_Fire release];
	[self.emitter_Flower release];
	[self.emitter_Galaxy release];
	[self.emitter_Meteor release];
	[self.emitter_Rain release];
	[self.emitter_Smoke release];
	[self.emitter_Spiral release];
	[self.emitter_Sun release];
	[self.emitter_Button release];
	[super dealloc];
}




@end
